﻿Pui.space = {
    init: function() {
        Pui.header.init();
        Pui.searching.init();
		if ('undefined' == typeof(json) || json) {
            if (_is_login) {
                this.islogin();
            } else {
                this.unlogin();
            }
        }
    },
	 unlogin: function() {
        var str = '';
        str += '<div class="row" id="topNav">';
        str += '<a title="登录" href="javascript:Pui.header.loginfo2(Pui.header.loginfo2_callback)">登录</a>';
        str += '<a title="注册" href="http://www.pomoho.com/ui/reg.aspx" target="_blank">注册</a>';
        if (document.location.host.toString().indexOf('home.pomoho.com') != -1) {
            str += '<a target="_blank" href="http://bbs.pomoho.com">论坛</a>';
        } else {
            str += '<a href="http://www.pomoho.com/upload/" target="_blank" title="论坛">论坛</a>';
        }
        str += '</div>';
        $("#top_Nav #L").html(str);
    },
	islogin: function() {
        var str = '';
        str += '<div class="row" id="topNav">';
        str += '<span class="s"><a class="count" title="你的帐户" href="http://www.pomoho.com/manage/index.aspx" target="_blank" >帐户</a>';
        str += '   <div class="dbd s3">';
        str += '     <ul>';
        str += '       <li><a class="d_item" title="我的视频" href="http://www.pomoho.com/manage/managevideo.aspx" target="_blank" >我的视频</a></li>';
        str += '       <li><a class="d_item" title="我的订阅" href="http://www.pomoho.com/manage/subscribevblog.aspx" target="_blank" >我的订阅</a></li>';
        str += '       <li><a class="d_item" title="我的收藏" href="http://www.pomoho.com/manage/managevideo.aspx?type=favs" target="_blank" >我的收藏</a></li>';
        str += '       <li><a class="d_item" title="我的相册" href="http://www.pomoho.com/manage/managealbum.aspx" target="_blank" >我的相册</a></li>';
        str += '     </ul>';
        str += '     <div class="m1"><a title="更多管理" href="http://www.pomoho.com/manage/index.aspx" target="_blank" >更多..&nbsp;&nbsp;</a></div>';
        str += '   </div>';
        str += ' </span>';
        if (document.location.host.toString().indexOf('home.pomoho.com') != -1) {
			str += ' <span class="s"><a class="msg" title="你的消息" href="http://www.pomoho.com/manage/messagelist.aspx?type=1" target="_blank" >消息</a><span>(0)</span>';
            str += '   <div class="dbd s2">';
            str += '     <div class="title"><div class="d_video">主题</div><div class="d_author">消息来源</div></div>';
            str += '     <ul>';
            str += '     </ul>';
            str += '     <div class="m"><a title="全部消息" href="http://www.pomoho.com/manage/messagelist.aspx?type=1" target="_blank" >全部消息&gt;&gt;</a></div>';
            str += '   </div>';
            str += ' </span>';
        } else {
			str += '<a target="_blank" href="http://bbs.pomoho.com">论坛</a>';  
        }
        str += ' <a title="退出登录" href="http://www.pomoho.com/ui/logout.aspx?AfterLoginReturnURL=' + window.location + '" >退出</a>';
        str += '</div>';
        $("#L").removeClass().html(str);
        this.SH();
        Pui.loadScript("http://notice.pomoho.com/loadmessage2.0.aspx?v=3");
    },
	SH: function() {
        var tim;
        $("#top_Nav #L .s").hover(function() {
            $(this).siblings().find(".dbd").hide();
            $(this).find(".dbd").show();
            clearTimeout(tim);
        },
        function() {
            tim = setTimeout(overDiv, 500);
            function overDiv() {
                $(this).find(".dbd").slideUp();
            }
        });
	},
    logInfo: function() {
        $('<div id="top_Nav"><div class="out" id="L"><ul><li class="s1 log"><a title="" href="javascript:Pui.header.loginfo2(Pui.header.loginfo2_callback);">登录</a></li><li class="s2 reg"><a href="http://www.pomoho.com/ui/reg.aspx" target="_blank">注册</a></li><li class="s2"><a target="_blank" href="http://bbs.pomoho.com">论坛</a></li></ul></div></div><script type="text/javascript">Pui.header.init();</script>').prependTo('#SpaceTitle');
    },
    emotion: function(what) {
        var emotionID = 1;
        $(what + ' .emotion').find('.l').click(function() {
            if (emotionID >= 2) {
                $('#emotionBox').animate({
                    left: -(450 * (emotionID - 2))
                },
                1000);
                if (emotionID == 2) {
                    $(what + ' .l').removeClass('l_b').attr('title', '左边没有了');
                } else if (emotionID == 4) {
                    $(what + ' .r').addClass('r_b').attr('title', '向右翻');
                }
                emotionID--;
            }
            this.blur();
            return false;
        }).end().find('.r').click(function() {
            if (emotionID <= 3) {
                $('#emotionBox').animate({
                    left: -(450 * emotionID)
                },
                1000);
                if (emotionID == 1) {
                    $(what + ' .l').addClass('l_b').attr('title', '向左翻');
                } else if (emotionID == 3) {
                    $(what + ' .r').removeClass('r_b').attr('title', '右边没有了');
                }
                emotionID++;
            }
            this.blur();
            return false;
        }).end().find('div a').each(function() {
            $(this).click(function() {
                var tmp = $(what + ' textarea').val() + $(this).find('img').attr('src').replace(/.+\/(em\d+)\.gif/g, '[$1]');
                $(what + ' textarea').val(tmp);
                return false;
            });
        });
    },
    emotionWR: function(what) {
        var s = '';
        s += '<div style="position:relative;width:450px;height:60px;overflow:hidden;margin:5px auto;"><div id="emotionBox" style="position:absolute;left:0;top:0;width:1800px;">';
        var l = 'http://static.pomoho.com/images/em/';
        var alt = ['黑星打', '大', '泡', '蹦', '继续', '狂', '黑星殴', '吹', '捅', '被殴', '飞', '嘘', '赖', '顶', '变', '滚球', '生', '膜拜', '转', '口', 'KI', '鬼', '抓狂', '扯', '流', '闭嘴', 'HI', '可爱', '摇', '躲', '多', '吉'];
        for (var i = 1; i <= 4; i++) {
            s += '<div style="width:450px;float:left;text-align:center;">';
            for (var j = (i - 1) * 8 + 1; j <= i * 8; j++) {
                if (j <= 32) {
                    s += '<a href="" title="' + alt[j - 1] + '" style="margin:0 1px;"><img src="' + l + 'em' + j + '.gif" height="50" width="50" /></a>';
                }
            }
            s += '</div>';
        }
        s += '</div></div>';
        s += '<a href="" class="l" title="左边没有了">向左翻</a><a href="" class="r r_b" title="向右翻">向右翻</a>';
        $(s).appendTo($('.emotion'));
        this.emotion(what);
        this.commentLoad();
    },
    commentLoad: function() {
        $('<div class="loading">评论加载中...</div>').insertBefore($('.commentAdd'));
        var sh = ("innerHeight" in window )?window.innerHeight:document.documentElement.offsetHeight;
        var comm = $('#Comment')[0];
        var commentTop = comm.offsetTop + 100;
        setTimeout(function(){
        var reviewNum=parseInt($('#Path').find('.c_review span').html());
        if (commentTop < sh && reviewNum>0) { 
	        Pui.ajaxLoad('GET', 'http://home.pomoho.com/do/interfaces/getvideoreview.aspx', 'videoid=' + flvid + '&r=' + Math.random(), 'html', '',
		        function() {
			        $('#Comment').prepend(_getDATA);
		        }
	        );
        } else if (commentTop >= sh && reviewNum>0) { (function g() {
	        if (document.documentElement.scrollTop + sh >= commentTop) {
		        Pui.ajaxLoad('GET', 'http://home.pomoho.com/do/interfaces/getvideoreview.aspx', 'videoid=' + flvid + '&r=' + Math.random(), 'html', '',
			        function() {
				       $('#Comment').prepend(_getDATA);
			        }
		         );
	        } else {setTimeout(function() {g();},2000);}
            })();
        }	
        },6000);
    },
    commentReply: function(what) {
        this.SetValidCodeImg(what);
        var _self = this;
        $('#post_content').bind('focus',
        function() {
            _self.CodeImgLoader()
        });
        $(what + ' input[type="submit"]').click(function() {
            textarea = $(what + ' textarea');
            if ($.trim(textarea.val()) == '') {
                alert('留言内容不可为空！');
                textarea.focus();
                return;
            }
            var sValidCode = "";
            if (document.getElementById("tb_validcode") != null) {
                sValidCode = document.getElementById("tb_validcode").value;
                if ($.trim(sValidCode) == '') {
                    alert('验证码不可为空！');
                    return;
                }
            }
            var content = textarea.val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
//            允许匿名访问
//            if (_is_login) {
                switch (what) {
                case '#Comment':
                    Pui.loadScript(baseurl + "/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                        random: true
                    });
                    break;
                case '#GuestBook':
                    Pui.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                        random: true
                    });
                }
                var ct = Pui.ui.pos.elementTop(document.getElementById(what.slice(1)));
                window.scrollTo(0, ct - 30);
                this.blur();
                setTimeout("Pui.space.commentReplyFill()", 1000);
                _self.GetValidCodeImg();
                return false;
//            } else {
//                flag = 6;
//                Pui.header.loginfo();
//            }
        });
    },
    commentJudge: function() {
        var sValidCode = document.getElementById("tb_validcode").value;
        if (document.getElementById('Comment')) {
            var content = $('#Comment textarea').val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
            Pui.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                random: true
            });
        } else if (document.getElementById('GuestBook')) {
            var content = $('#GuestBook textarea').val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
            Pui.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                random: true
            })
        }
        setTimeout("Pui.space.commentReplyFill()", 1000);
        Pui.space.GetValidCodeImg();
        Pui.header.closeDiv();
    },
    hideComment: function(num) {
        if (String(window.location).match(/http:\/\/home.*/)) {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        } else {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        }
        $('#Comment h3 span.count').html(20);
    },
    commentQuote: function(bid) {
        var re_q_txt = document.getElementById("re_q_" + bid).value;
        document.getElementById("post_content").value = "[quote]" + re_q_txt + "[/quote]";
        $('#Comment textarea').focus();
    },
    commentReplyFill: function() {
        var c = textarea.val().replace(/\[em(\d+)\]/g, "<img src='http://static.pomoho.com/images/em/em$1.gif' />");
        var u = _is_login ? '<a href="javascript:;">' + _user.nick + '</a>': '游客';
        var s = '';
        var mdL = $('#Comment .cl').length;
        var icount = $('#CM h3 .title span').text() ? $('#CM h3 .title span').text() : 0;
        icount = parseInt(icount);
        var vtitle = $.trim($('title').html());
        var s_href = 'http://video.pomoho.com/review.aspx?flvid=' + flvid + '&icount=' + (icount + 1) + '&title=' + vtitle + '&uid=' + _space_user.uid;
        if (mdL) {
            s += '<div class="mDocument" style="_width:100%;">';
            s += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            s += ' <div class="detail">';
            s += '  <span class="n_user">' + u + '</span>';
            s += '  <p class="text">' + c + '</p>';
            s += ' </div>';
            s += ' <div class="handle">';
            s += '  <span class="t_release">' + Pui.ui.gettime() + '</span>';
            s += ' </div>';
            s += '</div>';
            $('#Comment .cl').prepend(s).fadeTo('slow', 1);
            $('#CM h3 .title span').text(icount + 1).parents('h3').find('.more a').attr('href', s_href);
        } else {
            s += '<h3><span class="title">网友评论（共<span>' + (icount + 1) + '</span>条）</span><span class="more"><a target="_blank" href="' + s_href + '">更多</a></span></h3>';
            s += '<div class="cl showblock"><div class="mDocument">';
            s += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            s += ' <div class="detail">';
            s += '  <span class="n_user">' + u + '</span>';
            s += '  <p class="text">' + c + '</p>';
            s += ' </div>';
            s += ' <div class="handle">';
            s += '  <span class="t_release">' + Pui.ui.gettime() + '</span>';
            s += ' </div>';
            s += '</div></div>';
            $('#span_video_review').prepend(s).fadeTo('slow', 1);
        }
        textarea.attr('value', '').focus();
    },
    doingReply: function() {
        var timer_doing = null;
        $('#Doing input[@type=submit]').click(function() {
            var content = $.trim($('#Doing textarea').val());
            if (content == null) {
                alert('记事内容不可为空！');
                $('#Doing textarea').focus();
                return;
            }
            if (timer_doing != null) {
                var d = new Date();
                if ((Date.parse(d.toUTCString()) - 60000) < timer_doing) {
                    alert('留言间隔不得少于1分钟！');
                    $('#Doing textarea').focus();
                    return;
                }
            } else {
                var d = new Date();
                timer_doing = Date.parse(d.toUTCString());
            }
            var ct = Pui.pos.elementTop($('#Doing')[0]);
            window.scrollTo(0, ct - 30);
            this.blur();
            setTimeout("Pui.space.doingReplyFill()", 1000);
            var content = escape(content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace('\'', '‘'));
            Pui.loadScript(baseurl + "/space/mydoingajax.aspx?opreatetype=add&writecontent=" + content + "&userid=" + _space_user.uid, {
                random: false
            });
            return false;
        });
    },
    doingReplyFill: function() {
        var c = $.trim($('#Doing textarea').val());
        var s = '<li><div>' + c + '</div><p>书写于<span>现在</span><a href="javascript:;" onclick="$(this).parent().parent().hide()" class="is_login" title="删除">删</a></p></li>';
        if (!$('#Doing .nl')[0]) {
            $('#Doing h2').after('<div class="nl detail"></div>');
        }
        $(s).prependTo('#Doing .nl');
        $('#Doing textarea').attr('value', '').focus();
    },
    GetValidCodeImg: function() {
        ValidCodeURL = baseurl + "/video/ValidCode.aspx?type=1";
        document.getElementById('Comment') ? document.getElementById("validcode").src = ValidCodeURL + "&objid=" + flvid + "&ran=" + Math.random() : document.getElementById("validcode").src = ValidCodeURL + "&objid=" + _space_user.uid + "&ran=" + Math.random();
    },
    CodeImgLoader: function() {
        var s = '<a href="javascript:Pui.space.GetValidCodeImg();" title="看不清楚？请点击刷新验证码！" style="position:relative;top:-3px;*top:-2px;" ><img id="validcode" border=0  width="60" height="20" src="" /></a>';
        $('#tb_validcode').after(s).removeAttr('onfocus');
        $('#post_content').unbind('focus');
        $('#post_content').click(function() {
            if ($("#QuickComment").length > 0) {
                $(".f_v").hide();
                $("#QuickComment").hide();
            }
        });
		this.GetValidCodeImg();
    },
    SetValidCodeImg: function(what) {
        var ValidCodeHtml = '';
        ValidCodeHtml = '请输入验证码&nbsp;&nbsp;<input id="tb_validcode" type="text" onfocus="javascript:Pui.space.CodeImgLoader();" style="width:60px; border:1px #7B9EBD solid;margin:0 5px 0 0;" />';
        var s = $(what + ' .commentAdd .form .submit').html();
        $(what + ' .commentAdd .form .submit').html(ValidCodeHtml + s);
    },
    SendCallBack: function(v, sv) {
        if (v == 0) {
            alert("您的验证码错误！");
        }
        if (v == -1) {
            alert("您的验证码已失效。请点击验证码图片，重新获取验证码！");
        }
        setTimeout("$('#Comment .mDocument').eq(0).remove();", 1000);
        if ($('#Comment .cl').length > 1) {
            $('#Comment .cl').eq(0).remove();
            $('#Comment h3').eq(0).remove();
        }
        setTimeout("textarea.attr('value', '" + sv + "').focus();", 1000);
        setTimeout(function() {
            var icount = $('#CM h3 .title span').text() ? $('#CM h3 .title span').text() : 0;
            icount = parseInt(icount);
            var vtitle = $.trim($('title').html());
            var s_href = 'http://video.pomoho.com/review.aspx?flvid=' + flvid + '&icount=' + (icount - 1) + '&title=' + vtitle + '&uid=' + _space_user.uid;
            $('#Comment h3 .title span').text(icount - 1).parents('h3').find('.more a').attr('href', s_href);
        },
        1500);
    },
	conceal:function(){
		var page=$('.Popular .page li')
		page.click( function () {
			var page=$(this);
			if(page.parent().children().length<=1)return false;
			page.addClass('ac').siblings().removeClass('ac');
			var mm=page.parent().children().index(page[0]);
			page.parents('.Popular').find('.cover').css('display','none').eq(mm).css('display','block');
			return false;
		});
	}
}
/*播放页热门视频*/
function focusTurn(){
	var i=0,yc=$('.Popular .cover'),l=yc.length,s='';
	function num(){
		yc.parent().find('.page li').removeClass('ac').click(function(){
			clearTimeout(t);
			var _self=$(this);
			_self.addClass('ac');
			i=_self.text()-1;
			g();
			return false;											 
		});
	}
	function g(){
		yc.css('display','none').parent().find('.page li').removeClass('ac');
		if(i<l){
			yc.eq(i).css('display','block').parent().find('.page li:eq('+i+')').addClass('ac');
			i++;
			t=setTimeout(function(){g()},3000);
		}
		else{i=0;g();}
	}
	if(l){num();g();}
}
Pui.video = {
    channelID: -1,
    strTime: "24hour",
    videoTitle: document.title,
    init: function ()
    {
        if (typeof (channelId) != 'undefined')
        {
            Pui.video.channelID = channelId;
        }
        if (typeof (strTime) != 'undefined')
        {
            Pui.video.strTime = strTime;
        }
        if (typeof (videoTitle) != 'undefined')
        {
            Pui.video.videoTitle = videoTitle;
        }
        Pui.video.hotVideo();
        Pui.video.userVideoList();
        Pui.video.wideScreenAD();
        Pui.video.relateVideo();
        //2010-09-17 解决播放页原创不能点问题
        //$("#Menu>ul>li:last").html("<a target=\"_blank\" href=\"http://www.pomoho.com/dv/\">原创</a>");
    },
    quote: function (bid)
    {
        Pui.space.commentQuote.call(this, bid);
    },
    collect: function ()
    {
        Pui.space.video.collect.call(this);
    },
    hotVideo: function ()
    {
        var videoList = function (json)
        {
            var jsonlen = json.length;
            if (jsonlen > 9)
            {
                hotVideoPlay(json.slice(0, 9));
                hotVideoSearch(json.slice(9));
            }
            else
            {
                hotVideoSearch(json);
            }
        };
        var hotVideoSearch = function (arrJson)
        {
            $("<div>")
                    .attr({ id: "div_recommend" })
                    .insertAfter($("#div_relatedSearch"));

            var strLiList = '';
            for (var i = 0; i < arrJson.length; i++)
            {
                strLiList += "<li>";
                strLiList += "<a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(arrJson[i].videoName) + "&_f=P0S05&vid=" + arrJson[i].videoID + "\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\"><img alt=\"" + arrJson[i].videoName + "\" src=\"" + arrJson[i].imgURL + "\"></a>";
                strLiList += "<p><a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(arrJson[i].videoName) + "&_f=P0S05&vid=" + arrJson[i].videoID + "\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\">" + arrJson[i].videoName + "</a></p>";
                strLiList += "</li>";
            }
            var recommendBox = "<div class=\"videolist Recommend\">";
            recommendBox += "<div class=\"bt_title\"><h2>推荐视频</h2></div>";
            recommendBox += "<div class=\"showblock\">";
            recommendBox += "<ul>";
            recommendBox += strLiList;
            recommendBox += "</ul>";
            recommendBox += "</div>";
            recommendBox += "</div>";
            $("#div_recommend").html(recommendBox);
        };
        var hotVideoPlay = function (arrJson)
        {
            var more = arrJson[0].channelText || (typeof (channelEngName) == 'undefined' ? "" : channelEngName) || "mm";
            var strList = "<div class=\"Popular\" style=\"display:none\">";
            strList += "<div class=\"bt_title\"><a target=\"_blank\" href=\"http://www.pomoho.com/" + more + "/" + more + ",video,week,1\">更多</a><h2>热门视频</h2></div>";
            strList += "<div class=\"showblock\">";

            var strPage = '';
            var iPage = 1;
            for (var i = 0; i < arrJson.length; i++)
            {
                if (i % 3 == 0)
                {
                    strList += "<ul class=\"" + (i == 0 ? "cover" : "hide cover") + "\">";
                }

                strList += "<li>";
                strList += "<a href=\"" + arrJson[i].spaceURL + "/" + arrJson[i].videoID + "?P0P08\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\"><img alt=\"" + arrJson[i].videoName + "\" src=\"" + arrJson[i].imgURL + "\"></a>";
                strList += "<p><a href=\"" + arrJson[i].spaceURL + "/" + arrJson[i].videoID + "?P0P08\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\">" + arrJson[i].videoName + "</a></p>";
                strList += "</li>";

                if ((i + 1) % 3 == 0 || i == arrJson.length - 1)
                {
                    strList += "</ul>";
                    strPage += "<li " + (strPage == '' ? "class=\"ac\"" : "") + ">" + (iPage++) + "</li>";
                }
            }
            strList += "<div class=\"page\">";
            strList += "<ol>" + strPage + "</ol>";
            strList += "</div>";
            strList += "</div>";
            strList += "</div>";
            if ($("#ByRight .Popular").length > 0)
            {
                $("#ByRight .Popular").remove();
            }
            $("#ByRight").prepend(strList);
            $("#ByRight .Popular").slideDown(2500);
            focusTurn();
        };
        var jsonFun = function ()
        {
            $.getJSON("http://video.pomoho.com/do/interfaces/getchannelhotvideo.aspx?jsoncallback=?", { num: 19, cid: Pui.video.channelID, time: "24hour",add:1 }, function (json)
            {
                if (json != null && json.length > 0)
                {
                    videoList(json);
                }
            });
        }
        jsonFun();
    },
    userVideoList: function ()
    {
        var arrVideo = [
        "【笑掉大牙】老人【杰克逊模仿秀】|http://static.pomoho.com/pics/1_1_3963004498529.jpg|%e8%80%81%e4%ba%ba%e6%9d%b0%e5%85%8b%e9%80%8a%e6%a8%a1%e4%bb%bf%e7%a7%80|6303742",
        "当男医生遇到漂亮女病人|http://static.pomoho.com/pics/1_1_3963657717064.jpg|%e6%bc%82%e4%ba%ae%e5%a5%b3%e7%97%85%e4%ba%ba|6698819",
        "三个女人的震奶舞|http://static.pomoho.com/pics/1_1_3963873946304.jpg|%e9%9c%87%e5%a5%b6%e8%88%9e|6266029",
        "美女裸奔为环保性感雷人|http://static.pomoho.com/pics/1_1_3964381866289.jpg|%e7%be%8e%e5%a5%b3%e8%a3%b8%e5%a5%94%e4%b8%ba%e7%8e%af%e4%bf%9d%e6%80%a7%e6%84%9f%e9%9b%b7%e4%ba%ba|6658860",
        "日本萌系宅女瘦瘦操|http://static.pomoho.com/pics/1_1_3964627155239.jpg|%e6%97%a5%e6%9c%ac%e8%90%8c%e7%b3%bb%e5%ae%85%e5%a5%b3%e7%98%a6%e7%98%a6%e6%93%8d|6701999",
        "石光近00后教室热吻门|http://static.pomoho.com/pics/1_1_3964850258819.jpg|%e6%95%99%e5%ae%a4%e7%83%ad%e5%90%bb%e9%97%a8|5443613",
        "史上最雷人报警电话|http://static.pomoho.com/pics/1_1_3965105859279.jpg|%e9%9b%b7%e4%ba%ba|6163592",
        "最性感女教师朱松花|http://static.pomoho.com/pics/1_1_3966344959064.jpg|%e6%9c%80%e6%80%a7%e6%84%9f|6360412",
        "印度夜店震惊全世界|http://static.pomoho.com/pics/1_1_3966517442504.jpg|%e5%8d%b0%e5%ba%a6%e5%a4%9c%e5%ba%97|6608832",
        "哈利波特与死亡圣器预告|http://pic02.pomoho.com/grab_photo/201009/5899673.jpg|%e5%93%88%e5%88%a9%e6%b3%a2%e7%89%b9%e4%b8%8e%e6%ad%bb%e4%ba%a1%e5%9c%a3%e5%99%a8%e9%a2%84%e5%91%8a|5899673",
        ];
        var struserVideoList = "<div class=\"videolist\" id=\"Trundle\">";
        //struserVideoList+="<div class=\"bt_title\"><h2>该播客的视频列表</h2></div>";
        struserVideoList += "<div class=\"showblock\">";
        struserVideoList += "<div class=\"demo\">";
        var videoname = "";
        var videoimg = "";
        var enname = "";
        var vid = "";
        var arrtemp = [];
        var displayNum = Math.floor(Math.random() * (arrVideo.length - 2));
        struserVideoList += "<ul class=\"row\">";
        for (var i = 0; i < 3; i++)
        {
            arrtemp = arrVideo[displayNum++].split('|');
            if (arrtemp.length < 4)
            {
                return;
            }
            videoname = arrtemp[0];
            videoimg = arrtemp[1];
            enname = arrtemp[2];
            vid = arrtemp[3];
            struserVideoList += "<li>";
            struserVideoList += "<a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + enname + "&vid=" + vid + "&_f=P0S06\" title=\"" + videoname + "\" target=\"_blank\"><img alt=\"" + videoname + "\" src=\"" + videoimg + "\"></a>";
            struserVideoList += "<p><a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + enname + "&vid=" + vid + "&_f=P0S06\" title=\"" + videoname + "\" target=\"_blank\">" + videoname + "</a></p>";
            struserVideoList += "</li>";
        }
        struserVideoList += "</ul>";
        struserVideoList += "</div>";
        struserVideoList += "</div>";
        struserVideoList += "</div>";
        $("#Bar .videolist").eq(0).before(struserVideoList);
    },
    wideScreenAD: function ()
    {
        var sw = screen.width;
        if (typeof (sw) != 'undefined' && sw >= 1280)
        {
            var videoList = function (data)
            {
                var n = data.length, ul = document.createElement('ul');
                for (var i = 0; i < n; i++)
                {
                    var li = $('<li><a target="_blank" title="' + data[i].videoName + '" href="' + data[i].spaceURL + "/" + data[i].videoID + '?P0P09"><img src="' + data[i].imgURL + '" alt="' + data[i].videoName + '" /></a><p><a target="_blank" title="' + data[i].videoName + '" href="' + data[i].spaceURL + "/" + data[i].videoID + '?P0P09">' + data[i].videoName + '</a></p></li>');
                    $(ul).append(li);
                }
                $('#Space #ByRight').css({ 'float': 'left', 'margin': '0 15px' });
                $('#Space').width(1190).append($('<div class="videolist" style="width:190px;float:left;">').append('<div class="bt_title"><h2>昨日排行</h2></div>').append($('<div class="showblock" style="width:190px;"></div>').append(ul)));
            };
            var jsonFun = function ()
            {
                $.getJSON("http://video.pomoho.com/do/interfaces/getchannelhotvideo.aspx?jsoncallback=?", { num: 9, cid: -1, time: "24hour" }, function (json)
                {
                    if (json != null && json.length > 0)
                    {
                        videoList(json);
                    }
                });
            }
            jsonFun();
        }
    },
    relateVideo: function ()
    {
        var shwovideolist = function (list, title)
        {
            if (typeof (list) == "object" && !(list instanceof Array))
            {
                if (list.videoList instanceof Array)
                {
                    list = list.videoList;
                }
                else
                {
                    list = [];
                }
            }
            if (list.length == 0) return "";
            var fristKeywords = title || list[0].videoName;
            var fristKeywordstitle = decodeURIComponent(fristKeywords);
            var str = "<div class=\"videolist\">";
            str += "<div class=\"bt_title\"><a target=\"_blank\" href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + fristKeywords + "&_f=POSO3\">更多</a><h2>相关视频</h2></div>";
            str += "<div class=\"showblock\">";
            str += "<ul>";
            var tmpStatSource = "P0P07";
            var temp = ',' + fristKeywordstitle + ',';
            var num = 9;
            for (var i = 0; i < list.length && 0 < num; i++)
            {
                if (temp.indexOf(list[i].videoName) > -1)
                {
                    continue;
                }
                num--;
                temp += list[i].videoName + ",";
                str += "<li>";
                str += "<a href=\"http://home.pomoho.com/" + list[i].spaceURL + "/" + list[i].videoID + "?" + tmpStatSource + "\" target=\"_blank\" title=\"" + list[i].videoName + "\"><img src=\"" + list[i].imgURL + "\" alt=\"" + list[i].videoName + "\"/></a>";
                str += "<p><a href=\"http://home.pomoho.com/" + list[i].spaceURL + "/" + list[i].videoID + "?" + tmpStatSource + "\" target=\"_blank\" title=\"" + list[i].videoName + "\">" + list[i].videoName + "</a></p>";
                str += "</li>";
            }
            str += "</ul>";
            str += "</div>";
            str += "</div>";
            if (temp != (',' + fristKeywordstitle + ','))
            {
                $("#relateVideo").append(str);
            }
        }
        var jsonFun = function ()
        {
            if ($("#relateVideo").length > 0)
            {
                var videoID = typeof (flvid) == "undefined" ? 5610450 : flvid;
                var _title = Pui.video.videoTitle;
                $.getJSON("http://search.pomoho.com/getrelatvevideojson.aspx?jsoncallback=?", { count: 10, videoid: videoID, title: _title }, function (json)
                {                    
                    if (json != null && json.length > 0)
                    {
                        shwovideolist(json, _title);
                    }
                });
            }
        }
        jsonFun();
    }
}
Pui.space.video = {
    init: function ()
    {
        Pui.space.init();
        Pui.loadScript('http://live.pomoho.com/getxmldata.aspx?type=2&ids=' + flvid + '_999');
        Pui.space.emotionWR('#Comment');
        Pui.space.commentReply('#Comment');
        Pui.space.hideComment(5);
        Pui.autoThumb('.albumlist li img', 78, 58);
        Pui.video.init();
        if (document.getElementById('Space_NewVideo'))
        {
            this.gotoLink();
        };
    },
    share: function (link, title, content)
    {
        var itieba_share = 'http://tieba.baidu.com/i/sys/share?link=' + link + '&type=video&title=' + title + '&content=' + content;
        if (!window.open(itieba_share, 'itieba', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436'))
        {
            location.href = itieba_share;
        }
    },
    collect: function ()
    {
        Pui.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=2&imdbid=" + flvid);
    },
    gotoLink: function ()
    {
        var vTitle = encodeURIComponent($('title').html().replace(/(^\s*)|(\s*$)/g, ""));
        var vLink = encodeURIComponent('http://home.pomoho.com/' + _space_user.username + '/' + flvid);
        var vContent = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid);
        var vContentTieba = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid + '&qudao=tieba');
        var vBogo = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid + '&outall=true&qudao=51com');
        var vSource = encodeURIComponent('爆米花网');
        var vSourceUrl = encodeURIComponent('http://www.pomoho.com/');
        var s = '<span class="icos"><a id="wuyicom" href="http://diary.51.com/mod/diary_video_interface.php?vaddr=' + vBogo + '&title=' + vTitle + '&charset=utf-8" target="_blank" title="51交友社区">转贴至51交友社区</a><a id="QQ" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + vLink + '&title=' + vTitle + '&charset=utf-8" target="_blank" title="QQ空间">转贴至QQ空间</a><a id="renren" href="http://share.renren.com/share/buttonshare.do?link=' + vLink + '&title=' + vTitle + '" target="_blank" title="转贴至人人网">转贴至人人网</a><a id="kaixin" href="http://www.kaixin001.com/repaste/share.php?rurl=' + vLink + '&rcontent=' + vLink + '&rtitle=' + vTitle + '" target="_blank" title="转贴至开心网">转贴至开心网</a><a id="sina" href="http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pomoho_weibo&url=' + vLink + '&title=' + vTitle + '&source=' + vSource + '&sourceUrl=' + vSourceUrl + '&appkey=1854178289&pic=' + pic + '" target="_blank" title="转贴至新浪微博">转贴至新浪微博</a><a id="itieba" href="" onclick="Pui.space.video.share(\'' + vLink + '\',\'' + vTitle + '\',\'' + vContentTieba + '\');return false;" title="转贴至i贴吧">转贴至i贴吧</a></span><span class="GdIcos"><a id="feixin" href="http://space.fetion.com.cn/api/share?source=' + vSource + '&url=' + vLink + '&title=' + vTitle + '" title="转发至飞信空间">转发至飞信空间</a></span>';
        $(s).appendTo('.video_info .handle');
        this.zz();
    },
    zz: function (mv)
    {
        var urlParm = "";
        var htmlcode = '';
        var vTitle = encodeURIComponent($('title').html().replace(/(^\s*)|(\s*$)/g, ""));
        var vLink = 'http://home.pomoho.com/' + _space_user.username + '/' + flvid;
        var vContent = 'http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid + "&outall=true";
        var vSource = encodeURIComponent('爆米花网');
        var vSourceUrl = encodeURIComponent('http://www.pomoho.com/');
        var s = '';
        s += '<div id="ZZ" style="display:none;">';
        s += ' <div class="s1">';
        urlParm = "flvid";
        htmlcode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="396" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="' + vContent + '" /><embed src="' + vContent + '" quality="high" width="480" height="396" allowScriptAccess="always"/></object>';
        if (String(window.location).match(/http:\/\/video\.dvod.*/))
        {
            s += '  此节目地址（URL）<br /><input type="text" class="url" value="http://video.dvod.com.cn/news/' + flvid + '.shtml" /><br />';
        } else
        {
            s += '  此节目地址（URL）<br /><input type="text" class="url" value="' + vLink + '" /><br />';
        }
        s += '  把播放器显示到个人空间或Blog<br /><input type="text" class="url" value="' + vContent + '" /><br />';
        s += '  HTML代码,适用于个人空间（或其他类型的Blog）<br /><input type="text" class="url" value="" /><br />';
        s += '  BBS代码<br /><input type="text" class="url" value="[flash]' + vContent + '[/flash]" />';
        s += ' </div>';
        s += '  <p><a href="" onclick="$(\'#ZZ\').slideUp();return false;">关闭</a></p>';
        s += '</div>';
        var vPath = '#VideoPlayer .handle';
        $(s).appendTo($('#Space')).css({
            'z-index': '9999',
            'top': '402px',
            'left': '16px'
        });
        $(vPath).find('.s4').click(function ()
        {
            $('#ZZ').slideToggle('slow');
            this.blur();
            return false;
        });
        $('#ZZ .url').eq(2).attr('value', htmlcode).end().hover(function ()
        {
            $(this).select();
        },
        function ()
        {
            $(this).blur();
        });
    },
    hideComment: function (num)
    {
        if (String(window.location).match(/http:\/\/home.*/))
        {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        } else
        {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        }
        $('#Comment h3 span.count').html(20);
    }
}
Pui.space.guestbook = {
    init: function() {
        Pui.space.init();
        Pui.space.emotionWR('#GuestBook');
        Pui.space.commentReply('#GuestBook');
    }
}